package org.jarraiders.musiclibrary.client.view;

import org.jarraiders.musiclibrary.client.presenter.ArtistsPresenter;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.Widget;

public class ArtistsPopupPanel extends PopupPanel {
	private int index;
	private ArtistsPresenter presenter;

	private static final MyPopupPanelUiBinder binder = GWT.create(MyPopupPanelUiBinder.class);

	interface MyPopupPanelUiBinder extends UiBinder<Widget, ArtistsPopupPanel> {
	}
	private Listener listener;
	public interface Listener{
		public void onDelete();
	}
	@UiField
	Button editButton;
	@UiField
	Button deleteButton;
	
	public ArtistsPopupPanel(){
		setWidget(binder.createAndBindUi(this));
	}
	
	public ArtistsPopupPanel(int index) {
		this.index = index;
		setWidget(binder.createAndBindUi(this));
	}
	
	public ArtistsPopupPanel(int index, Listener listener) {
		this.index = index;
		setWidget(binder.createAndBindUi(this));
	}

	public ArtistsPopupPanel(int index, ArtistsPresenter presenter) {
		this.index = index;
		this.presenter=presenter;
		
		setWidget(binder.createAndBindUi(this));
	}

	@UiHandler("deleteButton")
	void onEditButtonClick(ClickEvent event) {
		if (presenter!=null){
			presenter.deleteSelectedArtist();
			
		}
	}
}
